--Matt Forbes
--11/23/09
--Assignment 4 Sudoku
--I didn't use the base files provided on the course website, but it still solves the puzzles :)

with sudoku;
use sudoku;
with ada.text_io;
with ada.characters.handling;

procedure assg4 is

   package t_io renames ada.text_io;
   package c_h renames ada.characters.handling;

   commentBuffer : String(1..100);
   c : Character;
   last : Integer;
   puzzleFile : t_io.file_type;
   EOL : Boolean;

begin
   t_io.Open(file => puzzleFile, name => "puzzles.txt", mode => t_io.In_File);
   loop
      EOL := false;
      t_io.look_ahead(puzzleFile, c, EOL);
      while EOL = true loop
         t_io.Skip_Line(puzzleFile);
         t_io.look_ahead(puzzleFile, c, EOL);
      end loop;
      if c = '#' then
         t_io.get_line(puzzleFile, commentBuffer, last);
         t_io.put_line(commentBuffer(2..last));
         t_io.Skip_Line(puzzleFile);
         t_io.new_line;
      elsif c_h.is_digit(c) or c = '.' then
         --ENTRY POINT
         doPuzzle(puzzleFile);
         t_io.Look_Ahead(puzzleFile, c, EOL);
      else
         t_io.get(puzzleFile, c);
      end if;
      exit when t_io.End_Of_File(puzzleFile);
   end loop;
   t_io.get(c);
end assg4;

